
<%@ page import="pl.dmcs.grails.Employee" %>
<!DOCTYPE html>
<html>
    <head>
        <meta name="layout" content="main">
        <link rel="stylesheet" href="${resource(dir: 'css/employee', file: 'form.css')}" type="text/css">
        <g:set var="entityName" value="${message(code: 'employee.label', default: 'Employee')}" />
        <title><g:message code="default.show.label" args="[entityName]" /></title>
    </head>
    <body>
        <a href="#show-employee" class="skip" tabindex="-1"><g:message code="default.link.skip.label" default="Skip to content&hellip;"/></a>
        <div class="nav" role="navigation">
            <ul>
                <li><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li>
                <li><g:link class="list" action="index"><g:message code="default.list.label" args="[entityName]" /></g:link></li>
                <li><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></li>
                </ul>
            </div>
            <div id="show-employee" class="content scaffold-show" role="main">
                <h1><g:message code="default.show.label" args="[entityName]" /></h1>
            <g:if test="${flash.message}">
                <div class="message" role="status">${flash.message}</div>
            </g:if>
            <ol class="property-list employee">
                <g:if test="${employeeInstance?.avatar}">
                    <div class="img-container">
                        <g:if test="${employeeInstance.avatar}">
                            <img class="form-img" src="${createLink(controller:'employee', action:'getAvatar', id:employeeInstance.id)}" />
                        </g:if>
                    </div>
                </g:if>
                
                <g:if test="${employeeInstance?.firstName}">
                    <li class="fieldcontain">
                        <span id="firstName-label" class="property-label"><g:message code="employee.firstName.label" default="First Name" /></span>

                        <span class="property-value" aria-labelledby="firstName-label"><g:fieldValue bean="${employeeInstance}" field="firstName"/></span>

                    </li>
                </g:if>

                <g:if test="${employeeInstance?.lastName}">
                    <li class="fieldcontain">
                        <span id="lastName-label" class="property-label"><g:message code="employee.lastName.label" default="Last Name" /></span>

                        <span class="property-value" aria-labelledby="lastName-label"><g:fieldValue bean="${employeeInstance}" field="lastName"/></span>

                    </li>
                </g:if>

                <g:if test="${employeeInstance?.title}">
                    <li class="fieldcontain">
                        <span id="title-label" class="property-label"><g:message code="employee.title.label" default="Title" /></span>

                        <span class="property-value" aria-labelledby="title-label"><g:fieldValue bean="${employeeInstance}" field="title"/></span>
                    </li>
                </g:if>

                <g:if test="${employeeInstance?.email}">
                    <li class="fieldcontain">
                        <span id="email-label" class="property-label"><g:message code="employee.email.label" default="Email" /></span>

                        <span class="property-value" aria-labelledby="email-label"><g:fieldValue bean="${employeeInstance}" field="email"/></span>

                    </li>
                </g:if>

                <g:if test="${employeeInstance?.room}">
                    <li class="fieldcontain">
                        <span id="room-label" class="property-label"><g:message code="employee.room.label" default="Room" /></span>

                        <span class="property-value" aria-labelledby="room-label"><g:fieldValue bean="${employeeInstance}" field="room"/></span>
                    </li>
                </g:if>
				
				<g:if test="${employeeInstance?.employeeCategories}">
                    <li class="fieldcontain">
                        <span id="employeeCategories-label" class="property-label"><g:message code="employee.employeeCategories.label" default="Employee Categories" /></span>

                        <g:each in="${employeeInstance.employeeCategories}" var="e">
                            <span class="property-value" aria-labelledby="employeeCategories-label"><g:link controller="employeeCategory" action="show" id="${e.id}">${e?.encodeAsHTML()}</g:link></span>
                        </g:each>

                    </li>
                </g:if>
            </ol>
            <g:form url="[resource:employeeInstance, action:'delete']" method="DELETE">
                <fieldset class="form">
                    <div id="planner">
                        ${raw(planner)}
                    </div>
                </fieldset>
                <fieldset class="buttons">
					<sec:access expression="hasAnyRole('ROLE_DMCS_USER', 'ROLE_DMCS_ADMIN')">
						<g:set var="isAdmin" value="${false}" />
						<sec:access expression="hasRole('ROLE_DMCS_ADMIN')">
							<g:set var="isAdmin" value="${true}" />	
						</sec:access>

						<g:if test="${employeeInstance?.id?.toString() == sec.loggedInUserInfo(field: 'id')?.toString() || isAdmin}">
							<g:link class="edit" action="edit" resource="${employeeInstance}"><g:message code="default.button.edit.label" default="Edit" /></g:link>
						</g:if>
						<g:if test="${employeeInstance?.id?.toString() != sec.loggedInUserInfo(field: 'id')?.toString() && isAdmin}">
							<g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" />
						</g:if>
					</sec:access>
                </fieldset>
            </g:form>
        </div>
    </body>
</html>
